package wuke.dao.imp;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

import wuke.dao.DlDao;
import wuke.model.Dlb;
import wuke.utils.HibernateSessionFactory;

public class DlDaoImp implements DlDao {

	public Dlb vlidates(String xh, String kl) {
		
		
		
		try {
			Session session = HibernateSessionFactory.getSession();
			Transaction ts = session.beginTransaction();
			Query query = session.createQuery("from Dlb where xh=? and kl=?");
			query.setParameter(0, xh);
			query.setParameter(1, kl);
			query.setMaxResults(1);
			Dlb dlb = (Dlb) query.uniqueResult();
			
			ts.commit();
			session.clear();			
			
			if (dlb != null) {
				return dlb;
			} else {
				return null;
			}
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	
	}

}
